package com.eling.elcms.basedoc.service.impl;

import com.eling.elcms.basedoc.dao.ICommunityDataDao;
import com.eling.elcms.basedoc.model.CommunityData;
import com.eling.elcms.basedoc.service.ICommunityDataManager;
import com.eling.elcms.core.service.impl.GenericManagerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class CommunityDataManagerImpl extends GenericManagerImpl<CommunityData,Long> implements ICommunityDataManager{

	ICommunityDataDao serviceCommunitydao;
	
	@Autowired
	public void setDao(ICommunityDataDao dao) {
        this.dao = dao;
        this.serviceCommunitydao = dao;
    }

	@Override
	public CommunityData open(Long pkServiceCommunity) {
		CommunityData community = new CommunityData();
		community = dao.get(pkServiceCommunity);
		community.setStatus(CommunityData.Status.Setting);
		community.setEnableTime(new Date());
		return dao.save(community);
	}

	@Override
	public CommunityData close(Long pkServiceCommunity) {
		CommunityData community = new CommunityData();
		community = dao.get(pkServiceCommunity);
		community.setStatus(CommunityData.Status.BlockUp);
		community.setDisableTime(new Date());
		return dao.save(community);
	}
}
